package com.sm.honkon.ui.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.sm.honkon.R
import com.sm.honkon.data.bean.ControlLogCatEntity

class LogcatsAdapter(
    data: MutableList<ControlLogCatEntity> = arrayListOf(),
    layoutResIdRes: Int = R.layout.item_logcat
) :
    BaseQuickAdapter<ControlLogCatEntity, BaseViewHolder>(layoutResIdRes, data) {
    var selectPosition = -1
        set(value) {
            if (field == value) {
                return
            }
            field = value
            notifyDataSetChanged()
        }


    override fun convert(helper: BaseViewHolder, item: ControlLogCatEntity) {
        item.let {
            helper.apply {
                getView<TextView>(R.id.tv_control_id_title).text = it.id
                getView<TextView>(R.id.tv_control_treatment_conetnt_title).text = it.treatment_conetnt
                getView<TextView>(R.id.tv_control_bochang_title).text = it.bochang
                getView<TextView>(R.id.tv_control_maikuan_title).text = it.maikuan
                getView<TextView>(R.id.tv_control_midu_title).text = it.midu
                getView<TextView>(R.id.tv_control_pinglv_title).text = it.pinglv
                getView<TextView>(R.id.tv_control_zhijing_title).text = it.zhijing
                getView<TextView>(R.id.tv_control_shouju_type_title).text = it.shoujuType
                getView<TextView>(R.id.tv_control_fashu_title).text = it.count.toString()
                getView<TextView>(R.id.tv_control_handle_title).text = it.handlerName
                getView<TextView>(R.id.tv_control).isSelected = selectPosition == layoutPosition

            }
        }
    }

}